package com.binarycat.dynamiclimit.bean;

import java.util.concurrent.atomic.AtomicBoolean;

import com.codahale.metrics.MetricRegistry;
import com.google.common.util.concurrent.RateLimiter;

/**
 * 方法对应的限流数据封装
 * 
 * @author jjb
 * @date 2018/08/06
 */
public class MethodMappingLimitData extends AbstractMethodMappingLimitData {

    public MethodMappingLimitData() {}

    public MethodMappingLimitData(MetricRegistry metricRegistry) {
        super(metricRegistry);
    }

    /**
     * 方法对应实际的限流器
     */
    private RateLimiter rateLimiter;

    /**
     * 方法对应的限流开关(默认false:不限流)
     */
    private final AtomicBoolean limitRateStatus = new AtomicBoolean(false);

    /**
     * 度量的标识(方法名或者方法名拼接ip)
     */
    private String metricKey;

    public RateLimiter getRateLimiter() {
        return rateLimiter;
    }

    public void setRateLimiter(RateLimiter rateLimiter) {
        this.rateLimiter = rateLimiter;
    }

    public AtomicBoolean getLimitRateStatus() {
        return limitRateStatus;
    }

    public String getMetricKey() {
        return metricKey;
    }

    public void setMetricKey(String metricKey) {
        this.metricKey = metricKey;
    }

}
